import { Singleton } from '../Manager/BaseManager';
import { HandleCode, Handler, HandlerBase } from './Handler';
/* eslint-disable */

export class HandlerManager extends Singleton {
  className: string = 'HandlerManager';
  handles: Map<HandleCode, (...args: any[]) => void> = new Map();
  private handlers: HandlerBase[] = [];

  init() {
    /* mark{0} */
    this.registerHandler(new Handler.MainHandler());
    /* mark{1} */
  }

  registerHandler(handler: HandlerBase) {
    this.handlers.push(handler);
    for (let [handle, callback] of handler.handles) {
      this.handles.set(handle, callback);
    }
  }
}
